/*
package cn.oowoo.api.controller;

import cn.oowoo.common.dto.JSR303Dto;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import result.Result;


import java.util.ArrayList;
import java.util.List;

@Slf4j
@RequestMapping("JSR-303")
@RestController
public class JSR303TestController {

    @RequestMapping("add")
    public Result add(@Validated(JSR303Dto.Add.class) JSR303Dto jsr303Dto, BindingResult bindingResult){
        log.info("START-jsr303Dto:{}",JSON.toJSONString(jsr303Dto));
        if(bindingResult.hasErrors()){
            List<ObjectError> allErrors = bindingResult.getAllErrors();
            List<String> errorResult = new ArrayList<>();
            allErrors.forEach(x->{
                FieldError error = (FieldError)x;
                String err =   error.getField() + " : " + error.getDefaultMessage();
                log.info(err);
                errorResult.add(err);
            });
            return Result.fail(JSON.toJSONString(errorResult));
        }
        return Result.success("校验通过!");
    }

    @RequestMapping("update")
    public Result update(@Validated(JSR303Dto.Update.class) JSR303Dto jsr303Dto, BindingResult bindingResult){
        log.info("START-jsr303Dto:{}",JSON.toJSONString(jsr303Dto));
        if(bindingResult.hasErrors()){
            List<ObjectError> allErrors = bindingResult.getAllErrors();
            List<String> errorResult = new ArrayList<>();
            allErrors.forEach(x->{
                FieldError error = (FieldError)x;
                String err =   error.getField() + " : " + error.getDefaultMessage();
                log.info(err);
                errorResult.add(err);
            });
            return Result.fail(JSON.toJSONString(errorResult));
        }
        return Result.success("校验通过!");
    }

}
*/
